home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 117 / PC Guia 117.iso / Software / Utils / Software6 / Product3 / all-in-one_gestures-0.12.4-fx.xpi / install.js next >
Text File  |  2004-09-09  |  3KB  |  58 lines

  1. const APP_DISPLAY_NAME = "All-in-One gestures";
  2. const APP_VERSION = "0.12.4";
  3. const APP_SHORT_NAME = "allinonegest";
  4. const APP_AUTHOR = "Marc_Boullet";
  5. const APP_PACKAGE = "/" + APP_AUTHOR + "/" + APP_SHORT_NAME;
  6. const APP_JAR_FILE = APP_SHORT_NAME + ".jar";
  7. const APP_CONTENT_FOLDER = "content/" + APP_SHORT_NAME + "/";
  8. const APP_LOCALE_FOLDER  = "locale/en-US/" + APP_SHORT_NAME + "/";
  9. const BLD_XUL_TREE_REWRITE = 20000417;
  10. const BLD_XPI_RESTART_MESSAGE = 20031211;
  11. const APP_WHERE_MESSAGE = "Install " + APP_DISPLAY_NAME + " to your profile folder (OK) or to your program folder (Cancel) ?";
  12. const APP_BUILD_TOO_OLD = APP_DISPLAY_NAME + " " + APP_VERSION + " must be installed to builds released after " + BLD_XUL_TREE_REWRITE + " !";
  13.  
  14. var currBuild = new String(buildID).substr(0, 8) - 0;
  15. if (currBuild && currBuild < BLD_XUL_TREE_REWRITE) {
  16.    alert(APP_BUILD_TOO_OLD);
  17.    cancelInstall();
  18. }
  19. else {
  20.    initInstall(APP_DISPLAY_NAME, APP_SHORT_NAME, APP_VERSION);
  21.    var where, chromef;
  22.    var inProfile = confirm(APP_WHERE_MESSAGE);
  23.    if (inProfile) {
  24.       chromef = getFolder("Profile", "chrome");
  25.       where = PROFILE_CHROME;
  26.    }
  27.    else {
  28.       chromef = getFolder("chrome");
  29.       where = DELAYED_CHROME;
  30.    }
  31.    var err = addFile(APP_PACKAGE, APP_VERSION, "chrome/" + APP_JAR_FILE, chromef, null);
  32.    if (err == SUCCESS) {
  33.       var jar = getFolder(chromef, APP_JAR_FILE);
  34.       registerChrome(CONTENT | where, jar, APP_CONTENT_FOLDER);
  35.       registerChrome(LOCALE  | where, jar, APP_LOCALE_FOLDER);
  36.       performInstall();
  37.       err = getLastError();
  38.       if (err == SUCCESS) {
  39. //         if (currBuild && currBuild < BLD_XPI_RESTART_MESSAGE)
  40.             alert(APP_DISPLAY_NAME + " version " + APP_VERSION + " has been successfully installed to your " +
  41.                (inProfile?"profile":"program") + " folder.\n\n" +
  42.            "Please, restart Firefox before continuing!");
  43.       }
  44.       else {
  45.          if (err == REBOOT_NEEDED) alert("Install failed because a previous version of " + APP_DISPLAY_NAME + " has not been uninstalled.");
  46.          else alert("Install failed! Error code:" + err);
  47.          cancelInstall(err);
  48.       }
  49.    }
  50.    else {
  51.       alert("Failed to create " + APP_JAR_FILE +"\n" +
  52.             "You probably don't have appropriate permissions \n" +
  53.             "(write access to " + (inProfile?"profile":"Firefox") + "/chrome directory). \n" +
  54.             "_____________________________\nError code:" + err);
  55.       cancelInstall(err);
  56.    }
  57. }
  58.